package com.company.Lab5;

import com.company.Utils.MatrixUtils;

import java.util.Scanner;

public class Fuzzy {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int r, c;
        double exponent;
        double alphaX;
        double[] alpha;
        String[] priority;
        double[][] initMatrix;
        double[][] distanceMatrix;
        double[][] xMatrix;
        double[][] finalMatrixBeloging;
        double optimist = 0;
        double pessimist = 0;
        double realist = 0;
        double regret = 0;
        double echiprob = 0;

        System.out.print("Introduceti numarul de randuri : ");
        r = scanner.nextInt();
        System.out.print("Introduceti numarul de coloane : ");
        c = scanner.nextInt();


        priority = new String[c];
        alpha = new double[c];
        initMatrix = new double[r][c];

        System.out.println("Introduceti priotitatea : ");
        for (int i = 0; i < c; i++) {
            System.out.print("Prioritatea [" + i + "] : ");
            if (i == 0) {
                scanner.nextLine();
            }
            priority[i] = scanner.nextLine();
        }
        System.out.println("Introduceti coeficientul alpha pentru fiecare coloana : ");
        for (int i = 0; i < c; i++) {
            System.out.print("Alpha [" + i + "] : ");
            alpha[i] = scanner.nextDouble();
        }
        System.out.print("Introduceti coeficientul alpha pentru toata matricea : ");
        alphaX = scanner.nextDouble();
        System.out.print("Introduceti exponenta :");
        exponent = scanner.nextDouble();

        initMatrix = MatrixUtils.readMatrix(r, c);
        distanceMatrix = MatrixUtils.calcGrDepartare(initMatrix, priority, r, c);
        xMatrix = MatrixUtils.calcXMatrix(distanceMatrix, alpha, r, c);
        finalMatrixBeloging = MatrixUtils.calcBelogingMatrix(xMatrix, exponent,priority, r, c);

        optimist = MatrixUtils.getOptimist(finalMatrixBeloging, r, c);
        pessimist = MatrixUtils.getPessimist(finalMatrixBeloging, r, c);
        realist = MatrixUtils.getRealist(finalMatrixBeloging, r, c, alphaX);
        regret = MatrixUtils.getRegret(finalMatrixBeloging, r, c);
        echiprob = MatrixUtils.getEchiprob(finalMatrixBeloging, r, c);

        System.out.println("Optimist : " + optimist);
        System.out.println("Pessimist : " + pessimist);
        System.out.println("Realist : " + realist);
        System.out.println("Regret : " + regret);
        System.out.println("Echiprob : " + echiprob);
    }
}
